package com.zyajac.springBootDemo.service.Impl;

import com.zyajac.springBootDemo.commonUtils.CommonUtils;
import com.zyajac.springBootDemo.dao.DaoSupport;
import com.zyajac.springBootDemo.dao.Redis.RedisUtil;
import com.zyajac.springBootDemo.entity.User;
import com.zyajac.springBootDemo.enums.ResultEnum;
import com.zyajac.springBootDemo.service.LoginService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Map;


@Service("LoginService")
public class LoginServiceImpl implements LoginService {

    @Resource(name = "DaoSupport")
    private DaoSupport daoSupport;

    @Resource
    private RedisUtil redisUtil;

    @Override
    public Map<String , Object> login(String params){

        Integer id = 2;

        Object user  = daoSupport.select("UserMapper.findUserById", id);

        Map<String, Object> result = CommonUtils.setResult(ResultEnum.OK);

        result.put("user", user);

        return result;
    }


    /**
      *
      * @author LZG
      * @date  2019/8/11
      * @param  params 登录
      * @return state
      **/
    public Map<String ,Object > loginout(String  params){
        if( params == null  ||  StringUtils.isBlank(params)) return CommonUtils.setResult(ResultEnum.BLANK_PARAM );

        User user = redisUtil.get("UserId");

        return null;
    }

}
